The VBA RTRIM Function returns a string after removing spaces from the right of the string.
RTrim(text)
Remove spaces from the right side of a string only:
Sub RTrimExample()
MsgBox RTrim(" test") 'Returns : " test"
MsgBox RTrim("test ") 'Returns : "test"
MsgBox RTrim(" test ") 'Returns : " test"
MsgBox RTrim(" test test ") 'Returns : " test test"
End Sub